(ns pathfinder
 (:import (java.io BufferedReader FileReader))
 (:use ('clojure.contrib.duck-streams))
 (:use ('clojure.contrib.seq-utils))
 )

(use 'read-print-map)
(use 'pathfinder-algorithm)

(def filename "map.txt")

(defn process-file [file-name]
  (with-open [rdr (BufferedReader. (FileReader. file-name))]
    (into [] (line-seq rdr))))

(def lines (process-file filename))

(def y-dimension (count lines))

(def matrix (read-print-map/create-matrix lines))

(find-path matrix)

(if (= pathfinder-algorithm/state "nsf")
  (println "The map is missing either the start or the finish position")
  (if (= pathfinder-algorithm/state "np")
    (println "There is no path from start to finish")
    (read-print-map/print-whole-map  pathfinder-algorithm/playground-map (- y-dimension 1))
    )
  )